using System;
using System.Collections.Generic;
using System.Text;

using phorm.database.core;
using phorm.config;

namespace phorm.model.fields
{
    /// <summary>
    /// A SQL Date/time column
    /// </summary>
    public class SQLDateTime : DatabaseColumn
    {
        /// <summary>
        /// Constructor initializes this column and populates to the model object.
        /// </summary>
        /// <param name="obj">The model object to which this column belongs</param>
        public SQLDateTime(DatabaseRecord obj)
        {
            this._model = obj;
            this.field_type = "datetime";
            populateColumn();
        }

        /// <summary>
        /// Method that calculates the current timestamp.
        /// </summary>
        /// <returns>Returns a date/time string formatted according to the configuration parameters</returns>
        public string now()
        {
            return DateTime.UtcNow.ToString(PhormConfig.phormParams.dateFormat);
        }
    }
}
